package com.engine4cloud.tdf.education.controller.web;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.data.web.response.Params;
import com.engine4cloud.tdf.education.dto.query.EduLearningRecordQueryDTO;
import com.engine4cloud.tdf.education.dto.result.EduLearningRecordResultDTO;
import com.engine4cloud.tdf.education.service.EduLearningRecordService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 学习记录表-web
 *
 * @author wenjie
 * @date 2024-08-15 15:06:54
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/web/learning/record")
@Tag(description = "eduLearningRecord", name = "学习记录表管理-web")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class EduLearningRecordWebController {

    private final EduLearningRecordService eduLearningRecordService;

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @param dto  学习记录表
     * @return R<PageInfo < EduLearningRecordResultDTO>>
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page")
    public R<PageInfo<EduLearningRecordResultDTO>> pageList(@ParameterObject Params page, @ParameterObject EduLearningRecordQueryDTO dto) {
        return R.ok(eduLearningRecordService.pageList(page, dto));
    }

    /**
     * 通过id查询学习记录表
     *
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<EduLearningRecordResultDTO> getById(@PathVariable("id") Long id) {
        return R.ok(eduLearningRecordService.getById(id));
    }
}